﻿using System;

namespace AutoBuild.Core
{
    public abstract class AbstractBuildRunner : IBuildRunner
    {
        protected AbstractBuildRunner()
        {
            BuildStarted += (s, e) => { };
            BuildCompleted += (s, e) => { };

        }

        //---- Events -----------------------------------------------------
        public event EventHandler<EventArgs> BuildStarted;
        public event EventHandler<EventArgs> BuildCompleted;
        
        //---------------------------------------------------------
        public abstract void RunBuild(AutoBuildArguments arguments);

        //---------------------------------------------------------
        public abstract string RunnerName { get; }

        //---------------------------------------------------------
        public virtual Type RunnerOptionsType { get; protected set; }

        //---------------------------------------------------------
        protected void OnBuildStarted()
        {
            BuildStarted(this, EventArgs.Empty);
        }

        //---------------------------------------------------------
        protected void OnBuildCompleted()
        {
            BuildCompleted(this, EventArgs.Empty);
        }

    }

    public abstract class AbstractBuildRunner<TRunnerOptions> : 
        AbstractBuildRunner, IBuildRunner<TRunnerOptions> where TRunnerOptions : class, new()
    {
        protected AbstractBuildRunner()
        {
        }

        //---------------------------------------------------------
        public override Type RunnerOptionsType
        {
            get { return typeof (TRunnerOptions); }
        }

       

    }
}